<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('customer')){
    function customer(){
        $CI = get_instance();
        
        $CI->load->model('Customers', '', true);
        return $CI->Customers->getListIndex();
    }
}

/**
 * Show categories
 * @author tien.nguyen
 */
if ( ! function_exists('categories')){
    function categories(){
        $CI = get_instance();
        
        $CI->load->model('Categories', '', true);
        return $CI->Categories->getOptions();
    }
}

if ( ! function_exists('video'))
{
    
    function video(){
        $CI = get_instance();
        
        $CI->load->model('Videos', '', true);
        return $CI->Videos->getListIndex();
    }

}

/**
 * Load config
 * @author tien.nguyen
 */
if ( ! function_exists('config')){
    function config(){
        $CI = get_instance();
        
        $CI->load->model('Configs', '', true);
        $res = $CI->Configs->getList();
        foreach($res as $key => $item){
            $CI->session->set_userdata('CONFIG_'.$key, $item);
        }
    }
}

/**
 * Check is active
 */
if ( ! function_exists('isActiveMenu')){    
    function isActiveMenu($params){
        $CI = & get_instance();
        $segments = $CI->router->uri->segments;
        //echo '<pre>'; print_r($segments);
        //echo '<pre>'; print_r($params);
        foreach($params as $key => $value){
            if(empty($segments[$key + 1])){                
                return false;
            }
            
            if($segments[$key + 1] != $value && !empty($value)){  
                //echo $segments[$key + 1] .'     '. $value; 
                return false;
            }
        }
        return true;
        /*
        if($menuName == $CI->router->class){
            return true;
        }else{
            return false;
        }*/
    }
}

?>